package cn.xiaopengstack.domain.activity.service.trialcal.node;

import cn.xiaopengstack.domain.activity.model.entity.MarketProductEntity;
import cn.xiaopengstack.domain.activity.model.entity.TrialCalculateEntity;
import cn.xiaopengstack.domain.activity.service.trialcal.AbstractGroupBuyMarketSupport;
import cn.xiaopengstack.domain.activity.service.trialcal.factory.DefaultActivityStrategyFactory;
import cn.xiaopengstack.types.framework.strategy.tree.StrategyHandler;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author jiangyangang
 */
@Component
public class SwitchNode extends AbstractGroupBuyMarketSupport {

    @Resource
    private MarketNode marketNode;

    @Override
    protected TrialCalculateEntity doApply(MarketProductEntity param, DefaultActivityStrategyFactory.DynamicContext dynamicContext) throws Exception {
        return route(param, dynamicContext);
    }

    @Override
    public StrategyHandler<MarketProductEntity, DefaultActivityStrategyFactory.DynamicContext, TrialCalculateEntity> get(MarketProductEntity param, DefaultActivityStrategyFactory.DynamicContext dynamicContext) throws Exception {
        return marketNode;
    }
}
